package lab15notepad;

public class Page {
	private String title;
	private String text;
	private static final String EMPTY="";
	
	public boolean searchWord (String word) {
		return text.contains(word);
	}
	
	public boolean containsDigits() {
		for (int i = 0; i < text.length(); i++)
		{
			if (text.charAt(i)>='0'&&text.charAt(i)<='9') return true;
		}
		return false;
	}
	
	public void append (String text) {
		if (text!=null) this.text+=text;
	}
	
	public void delete () {
		this.text=EMPTY;
	}
	
	public boolean isEmpty() {
		if (title==null||text==null) return false;
		return ((title==EMPTY)&&(text==EMPTY));
	}
	
	public Page() {
		super();
		this.title=EMPTY;
		this.text=EMPTY;
	}

	public void replace (String text) {
		delete();
		append(text);
	}
	
	public void setTitle(String title) {
		this.title=title;
	}
	
	public void view () {
		System.out.println(title);
		System.out.println(text);
	}
}
